package com.cloud.quickcore.admin.vo;

import com.cloud.quickcore.admin.entity.SysPermission;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 权限菜单表
 *
 * @author NiJo_H
 * @version 1.0
 * @date 2019/9/4 14:21
 */
@Data
@NoArgsConstructor
public class PermissionTree implements Comparable<PermissionTree> {
    private Long id;

    @ApiModelProperty("父级id")
    private Long parentId;

    @ApiModelProperty("名称")
    private String name;

    @ApiModelProperty("链接")
    private String url;

    @ApiModelProperty("排序号")
    private int soft;

    @ApiModelProperty("子菜单")
    private List<PermissionTree> children;

    public PermissionTree(SysPermission permission) {
        this.id = permission.getId();
        this.parentId = permission.getParentId();
        this.name = permission.getName();
        this.url = permission.getUrl();
        this.soft = permission.getSort();
    }

    @Override
    public int compareTo(PermissionTree o) {
        if(this.soft>o.getSoft()){
            return 1;
        }
        return -1;
    }
}
